<template>
	<view class="market-box">
		<!-- 寄售中心头部盒子 -->
		<view class="market-top-title" :style="'padding-top: '+stickyTop+'px;height:'+titleHeight+'px;'"
			:class="{'bg-fff':showWhiteBg}">
			寄售中心
		</view>
		<view class="market-top public345">

			<!-- 搜索框 -->
			<view class="search-box" @click="goToPage('/pages/search/search')">
				<u-search searchIconColor="#FF7803" searchIconSize="48" placeholder="热门轮播" height="80rpx" bgColor="#fff"
					:showAction="false">
				</u-search>
			</view>
			<!-- 右侧 我的寄售 -->
			<view class="market-top-right" @click="goToPage('/pages/mysell/mysell')">
				<image class="market-logo" :src="imageUrl('market-logo.png')" mode="widthFix"></image>
				<view>我的寄售</view>
			</view>
		</view>

		<!-- 吸顶 -->
		<view class="stickyTop" :style="'top:' + tabsStickyTop + 'px'" :class="{'bg-fff':navShowWhiteBg}">
			<!-- tabs -->
			<u-tabs :list="tarbbarList" lineWidth="40rpx" lineHeight="8rpx" lineColor="#FF7803" :activeStyle="{
					color: '#333',
					fontWeight: '600'
				}" @click="clickOneTab">
			</u-tabs>
		</view>

		<!-- 寄售列表 -->
		<view class="market-list public345">
			<!-- 左侧数据 -->
			<view class="market-list-left">
				<!-- 单个商品 -->
				<view class="one-item" @click="goToPage('/pages/tabbar/market/MarketDetail')">
					<!-- 商品图片 -->
					<image :src="imagesUrl('market-demo1.png')" mode="" />
					<!-- 商品名称 -->
					<view class="one-item-name">
						商品名称商品名称商品
					</view>
					<!-- 商品价格 -->
					<view class="one-item-price">
						￥
						<text style="font-size: 32rpx;">39.00</text>
						起
					</view>
				</view>
				<view class="one-item">
					<image :src="imagesUrl('market-demo2.png')" mode="" />
					<view class="one-item-name">
						商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
					</view>
					<view class="one-item-price">
						￥
						<text style="font-size: 32rpx;">39.00</text>
						起
					</view>
				</view>
			</view>

			<!-- 右侧数据 -->
			<view class="market-list-right">
				<view class="one-item">
					<image :src="imagesUrl('market-demo3.png')" mode="" />
					<view class="one-item-name">
						商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
					</view>
					<view class="one-item-price">
						￥
						<text style="font-size: 32rpx;">39.00</text>
						起
					</view>
				</view>
				<view class="one-item">
					<image :src="imagesUrl('market-demo4.png')" mode="" />
					<view class="one-item-name">
						商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
					</view>
					<view class="one-item-price">
						￥
						<text style="font-size: 32rpx;">39.00</text>
						起
					</view>
				</view>
				<view class="one-item">
					<image :src="imagesUrl('market-demo1.png')" mode="" />
					<view class="one-item-name">
						商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
					</view>
					<view class="one-item-price">
						￥
						<text style="font-size: 32rpx;">39.00</text>
						起
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 吸顶
				stickyTop: 0,
				// 白色背景
				showWhiteBg: false,
				navShowWhiteBg: false,
				titleHeight: 32,
				// 导航条列表
				tarbbarList: [{
					name: '全部',
				}, {
					name: '潮玩盲盒'
				}, {
					name: '动漫手办'
				}, {
					name: '3C数码'
				}, {
					name: '美妆'
				}],

			}
		},
		methods: {
			clickOneTab(item) {
				console.log('item', item.name);
			},
			// 跳转
			goToPage(url) {
				uni.navigateTo({
					url
				})
			},
			scrollEvent(val) {
				this.showWhiteBg = val > 0
				this.navShowWhiteBg = Math.floor(val) > this.tabsStickyTop
			}
		},
		computed: {
			tabsStickyTop() {
				return this.stickyTop + 32
			}
		},
		onPageScroll(e) {
			// console.log("滚动距离为：" + e.scrollTop);
			this.scrollEvent(e.scrollTop)
		},
		mounted() {
			this.stickyTop = uni.getSystemInfoSync().statusBarHeight

			// #ifdef MP-WEIXIN
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			this.titleHeight = menuButtonInfo.bottom
			// #endif

			// #ifdef APP-PLUS
			this.titleHeight = this.stickyTop + 36
			// #endif
		}
	}
</script>

<style lang="scss" scoped>
	// 寄售中心盒子
	.market-box {
		position: relative;
		width: 100vw;

		&::before {
			position: absolute;
			top: -212rpx;
			left: -212rpx;
			content: '';
			display: block;
			width: 424rpx;
			height: 424rpx;
			border-radius: 50%;
			opacity: 1;
			background: #FF9C47;
			filter: blur(300rpx);
			z-index: -99;
		}

		&::after {
			position: absolute;
			top: -117rpx;
			right: -117rpx;
			content: '';
			display: block;
			width: 234rpx;
			height: 234rpx;
			border-radius: 50%;
			opacity: 1;
			background: #FFF200;
			filter: blur(300rpx);
			z-index: -99;
		}

		// 粘性布局
		.stickyTop {
			position: sticky;
			// top: 88rpx;
			padding: 0 0 20rpx;
			z-index: 99;

			&.bg-fff {
				background: #fff;
			}
		}

		.market-top-title {
			position: sticky;
			top: 0;
			padding-left: 30rpx;
			font-size: 36rpx;
			font-weight: 500;
			line-height: 64rpx;

			&.bg-fff {
				background: #fff;
				z-index: 99;
			}
		}

		// 寄售中心顶部盒子
		.market-top {
			display: flex;
			justify-content: space-between;

			padding-top: 10rpx;
			padding-bottom: 10rpx;

			.search-box {
				width: 580rpx;
				padding: 10rpx 0;
			}

			// 右侧logo 我的寄售
			.market-top-right {
				width: 100rpx;
				padding-top: 12rpx;
				font-size: 20rpx;
				line-height: 24rpx;
				text-align: center;

				.market-logo {
					width: 56rpx;
					height: 56rpx;
					margin: 0 auto;
				}
			}
		}

		// 寄售列表
		.market-list {
			display: flex;
			padding-top: 18rpx;

			.market-list-left {
				margin-right: 18rpx;
			}

			.one-item {
				background-color: #fff;
				margin-bottom: 18rpx;
				border-radius: 16rpx;

				>image {
					width: 336rpx;
					height: 336rpx;
				}

				.one-item-name {
					margin: 24rpx 16rpx;
					font-size: 28rpx;
					color: #333;
					// 溢出隐藏
					-webkit-line-clamp: 2;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.one-item-price {
					padding: 14rpx 0 24rpx 16rpx;
					color: #FF7803;
					font-size: 24rpx;
				}
			}
		}
	}
</style>